package com.simen.connectandroid.model;

import com.simen.connectandroid.constants.Constant;
import com.simen.hellobytes.StringUtil;
import com.simen.hellobytes.regular.RegularUtil;

/**
 * Created on 2021/10/30 14:49.
 *
 * @author Simen
 */
public class Device {

    private String adbDeviceName;//用于adb命令识别设备的名称
    private DeviceStatus status;
    private String name;//设备名称
    private String model;//设备型号
    private String brand;//设备品牌
    private String version;//系统版本
    private String sdkVersion;

    public Device() {
    }

    public Device(String name, DeviceStatus status) {
        this.adbDeviceName = name;
        this.status = status;
    }

    public String getAdbDeviceName() {
        return adbDeviceName;
    }

    public void setAdbDeviceName(String adbDeviceName) {
        this.adbDeviceName = adbDeviceName;
    }

    public DeviceStatus getStatus() {
        return status;
    }

    public void setStatus(DeviceStatus status) {
        this.status = status;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public void setSdkVersion(String sdkVersion) {
        this.sdkVersion = sdkVersion;
    }

    public String getSdkVersion() {
        return sdkVersion;
    }

    @Override
    public String toString() {
        return "Device{" +
                "adbDeviceName='" + adbDeviceName + '\'' +
                ", status=" + status +
                ", name='" + name + '\'' +
                ", model='" + model + '\'' +
                ", brand='" + brand + '\'' +
                ", version='" + version + '\'' +
                ", sdkVersion='" + sdkVersion + '\'' +
                '}';
    }

    public String getSimpleName() {
        return adbDeviceName +
                (StringUtil.isTrimNotEmpty(brand) ? (" " + brand) : "") +
                (StringUtil.isTrimNotEmpty(model) ? (" " + model) : "") +
                (StringUtil.isTrimNotEmpty(version) ? (" " + version) : "");
    }

    /**
     * @return 是否为网络连接设备
     */
    public boolean isNetDevice() {
        return RegularUtil.match(adbDeviceName, Constant.REGULAR_IPWITHPORT_ADDRESS);
    }
}
